<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="sec" uri="http://www.springframework.org/security/tags" %>

<sec:authentication property="principal" var="currentPrincipal" scope="page" />

<div class="modal-dialog x-modal-dialog" style="width: 600px;">

  <div class="modal-content">

    <div class="modal-header x-breadcrumb clearfix">

      <h2><i class="glyphicon glyphicon-fire" title=""></i>&nbsp;&nbsp;<span>添加体验课</span></h2>

      <button type="button" class="close" data-dismiss="modal">&times;</button>

    </div>

    <form class="form-horizontal" method="POST" action="${ctx.host}/experience-orders/create-experience" data-validate = "true">

      <c:if test="${currentPrincipal.siteManager or currentPrincipal.siteServer}">
        <input type="hidden" name="siteId" value="${currentPrincipal.site.id}">
      </c:if>

      <div class="modal-body">
        <c:if test="${currentPrincipal.root or currentPrincipal.admin or currentPrincipal.areaServer or currentPrincipal.areaManager}">
          <div class="form-group x-form-group">
            <label class="col-xs-3 control-label">门店</label>
            <div class="col-xs-7" style="width: 60%;">
              <select name="siteId" class="form-control" data-validate="required">
                <c:forEach var="site" items="${persist.getSites(currentPrincipal.id)}">
                   <option value ="${site.id}">${site.name}</option>
                </c:forEach>
              </select>
            </div>
          </div>
        </c:if>
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">产品</label>
          <div class="col-xs-7" style="width: 60%;">
            <select name="productId" class="form-control select2" data-validate="required">
              <option></option>
              <!-- <option value = "38">1v1私教体验课单节</option> -->
              <option value = "3085">1v1体验周卡</option>
              <option value = "3089">常规体验课周卡</option>
              <option value = "3090">特色体验课周卡</option>
              <option value = "3087">迷你小课包</option>
              <option value = "3086">专项体态矫正管理周卡</option>
              <%-- <c:forEach var="product" items="${products}"> --%>
                 <%-- <option value = "${product.id}">${product.name}</option> --%>
              <%-- </c:forEach> --%>
            </select>
          </div>
        </div>
        
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">用户手机</label>
          <div class="col-xs-7">
            <input type="text" class="form-control" name="mobile" data-validate = "required|mobile" value="${param.mobile}" />
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">验证码</label>
          <div class="col-xs-4">
            <input type="text" class="form-control" name="code" data-validate="required" />
            <input type="hidden" class="form-control" name="token" />
          </div>
          <div class="col-xs-3">
            <button type="button" id="get-code" class="btn btn-primary form-control" style="height: 32px; padding: 0 .85rem;">获取验证码</button>
          </div>
        </div>
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">用户姓名</label>
          <div class="col-xs-7">
            <input type="text" class="form-control" name="name" data-validate = "required" value="${param.name}"/>
          </div>
        </div>
        
        <%-- <c:if test="${currentPrincipal.root or currentPrincipal.admin}"> --%>
        <div class="form-group x-form-group">
          <label class="col-xs-3 control-label">用户渠道</label>
          <div class="pull-left col-xs-7">
            <c:set value="${persist.listUserSourceTypeParent()}" var="typeParent" ></c:set>
            <c:set value="${persist.listUserSourceTypeChildren()}" var="typeChildrenMap" ></c:set>
            <select name="userSourceType" class="form-control" data-validate="required">
            
              <c:forEach var="typeParentItem" items="${typeParent}">
                <optgroup label="${typeParentItem.name}">
                  <c:choose>
                    <c:when test="${not empty typeChildrenMap[typeParentItem.id.toString()]}">
                      <c:forEach var="childrenTypes" items="${typeChildrenMap[typeParentItem.id.toString()]}">
                        <c:if test="${currentPrincipal.siteManager or currentPrincipal.siteServer}">
                          <c:choose>
                            <c:when test="${not empty childrenTypes.sites}">
                              <c:if test="${childrenTypes.sites.contains(currentPrincipal.site.code)}">
                                <option value="${childrenTypes.id}">${typeParentItem.name}-${childrenTypes.name}</option>
                              </c:if>
                            </c:when>
                            <c:otherwise>
                              <option value="${childrenTypes.id}">${typeParentItem.name}-${childrenTypes.name}</option>
                            </c:otherwise>
                          </c:choose>
                        </c:if>
                        <c:if test="${currentPrincipal.root or currentPrincipal.admin or currentPrincipal.areaServer or currentPrincipal.areaManager}">
                          <option value="${childrenTypes.id}">${typeParentItem.name}-${childrenTypes.name}</option>
                        </c:if>
                        
                      </c:forEach>
                    </c:when>
                    <c:otherwise>
                      <option value="${typeParentItem.id}">${typeParentItem.name}</option>
                    </c:otherwise>
                  </c:choose>
                </optgroup>
              </c:forEach>
            </select>
          </div>
        </div>
        <%-- </c:if> --%>
        
      </div>
        
      <div class="modal-footer">
        <button type="submit" class="btn btn-success btn-shadow btn-shadow-success x-btn">确定</button>&nbsp;&nbsp;&nbsp;&nbsp;
        <button type="button" class="btn btn-default btn-shadow btn-shadow-default x-btn" data-dismiss="modal">取消</button>
      </div>
    </form>
  </div>
</div>